package com.qihetimes.earthangel.service.impl;

import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qihetimes.earthangel.mapper.FeedbackMapper;
import com.qihetimes.earthangel.model.Feedback;
import com.qihetimes.earthangel.model.User;
import com.qihetimes.earthangel.service.IFeedbackService;
import com.qihetimes.earthangel.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * <p>
 * 意见反馈表 服务实现类
 * </p>
 *
 * @author f4cklangzi@gmail.com
 * @since 2021-12-18
 */
@Service
public class FeedbackServiceImpl extends ServiceImpl<FeedbackMapper, Feedback> implements IFeedbackService {
    
    @Resource
    private IUserService userService;
    
    @Override
    public void add(Feedback param) {
        User loginUser = userService.getLoginUser();
        param.setId(IdUtil.objectId());
        param.setUserId(loginUser.getId());
        param.setNickName(loginUser.getNickName());
        param.setAvatarUrl(loginUser.getAvatarUrl());
        param.setCreatedAt(LocalDateTime.now());
        save(param);
    }
}
